<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>SSE Demo</h1>
<div id="messages"></div>

<script>
    const eventSource = new EventSource('http://localhost:8001/sse/handleSse');
    const messages = document.getElementById('messages');
    eventSource.onmessage = function (event) {
        const message = document.createElement('p');
        message.textContent = event.data;
        messages.appendChild(message);
    };
    eventSource.onerror = function (error) {
        console.error('EventSource failed:', error);
        eventSource.close();
    };
    eventSource.onopen = function () {
        console.log('Connected to the server');
    };
</script>
</body>
</html>